part of '../repository.dart';

class _GooglePlayPurchasedItemDtoFactory {
  const _GooglePlayPurchasedItemDtoFactory._internal();

  static const _instance = _GooglePlayPurchasedItemDtoFactory._internal();

  factory _GooglePlayPurchasedItemDtoFactory() {
    return _instance;
  }

  _GooglePlayPurchasedItemDto fromJson(Map<String, dynamic> json) {
    final type = json[_kGooglePlayPurchasedItemTypeKey];

    if (type == _kGooglePlayPurchasedSubscriptionTypeValue) {
      return _GooglePlayPurchasedSubscriptionDto.fromJson(json);
    }

    if (type == _kGooglePlayOneTimePurchasedItemTypeValue) {
      return _GooglePlayOneTimePurchasedItemDto.fromJson(json);
    }

    throw UnimplementedError();
  }
}
